package com.cc.blog.admin.controller;

import com.cc.blog.admin.domain.dto.AddTagReqDTO;
import com.cc.blog.admin.domain.dto.DeleteTagReqDTO;
import com.cc.blog.admin.domain.dto.FindTagPageListReqDTO;
import com.cc.blog.admin.domain.dto.SearchTagsReqDTO;
import com.cc.blog.admin.service.AdminTagService;
import com.cc.blog.common.annotation.ApiOperationLog;
import com.cc.blog.common.utils.PageResult;
import com.cc.blog.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author cc
 * @Date 2024/7/10 17:03
 */
@RestController
@RequestMapping("/admin")
@Api(tags = "Admin 标签模块")
@AllArgsConstructor
public class AdminTagController {

    private final AdminTagService tagService;

    @PostMapping("/tag/add")
    @ApiOperation(value = "添加标签")
    @ApiOperationLog(description = "添加标签")
    public Result addTags(@RequestBody @Validated AddTagReqDTO addTagReqDTO) {
        return tagService.addTags(addTagReqDTO);
    }

    @PostMapping("/tag/list")
    @ApiOperation(value = "标签分页数据获取")
    @ApiOperationLog(description = "标签分页数据获取")
    public PageResult findTagPageList(@RequestBody @Validated FindTagPageListReqDTO findTagPageListReqDTO) {
        return tagService.findTagPageList(findTagPageListReqDTO);
    }

    @PostMapping("/tag/delete")
    @ApiOperation(value = "删除标签")
    @ApiOperationLog(description = "删除标签")
    public Result deleteTag(@RequestBody @Validated DeleteTagReqDTO deleteTagReqDTO) {
        return tagService.deleteTag(deleteTagReqDTO);
    }

    @PostMapping("/tag/search")
    @ApiOperation(value = "标签模糊查询")
    @ApiOperationLog(description = "标签模糊查询")
    public Result searchTags(@RequestBody @Validated SearchTagsReqDTO searchTagsReqDTO) {
        return tagService.searchTags(searchTagsReqDTO);
    }

    @PostMapping("/select/list")
    @ApiOperation(value = "查询标签 Select 列表数据")
    @ApiOperationLog(description = "查询标签 Select 列表数据")
    public Result findTagSelectList() {
        return tagService.findTagSelectList();
    }

}
